/**
 * Project  : monkey
 * Author   : Wu Tian Qiang
 * Date     : 2016/10/18 20:49:30
 */
Ext.define('Monkey.view.user.GrantRolePermissionWindow', {
    extend: 'Ext.window.Window',

    controller: 'ctrl-grantrolepermission',
    icon: 'resources/icons/16/text_shading.png',
    closable: true,
    resizable: true,
    constrain: true,
    constrainHeader: true,
    modal: true,
    frameHeader: false,
    frame: true,
    maximizable: false,
    layout: 'fit',
    width: 600,
    height: 500,
    userId: '',
    initComponent: function () {
        var me = this;
        var panel = Ext.create('Monkey.view.permission.GrantPermissionPanel', {
            moduleParam: 'userId',
            border: false,
            moduleValue: me.userId,
            getMenuPermissionURL: Monkey.URL.SERVER_URL + '/m/user/menu/permission.json',
            grantRecoveryPermissionURL: Monkey.URL.SERVER_URL + '/m/user/menu/permission.json'
        });
        var roles = Ext.create('Monkey.store.role.Role');
        var rolePanel = {
            border: false,
            xtype: 'itemselector',
            store: roles,
            displayField: 'display',
            valueField: 'id',
            fromTitle: '所有角色',
            toTitle: '已有角色',
            listeners: {
                change: 'saveRole',
                afterrender:'setAlreadyHaveRole'
            }
        };

        this.items = [{
            xtype: 'tabpanel',
            border: false,
            layout: 'fit',
            plain: true,
            items: [{
                border: false,
                icon: 'resources/icons/16/tag_green.png',
                title: '角色授权',
                html: '授权角色',
                layout: 'fit',
                bodyPadding: 1,
                items: [rolePanel]
            }, {
                border: false,
                icon: 'resources/icons/16/lightning.png',
                title: '权限授权',
                html: '授权权限',
                layout: 'fit',
                items: [panel]
            }]
        }];

        this.callParent();

    }
});